#include "config/type.h"
#include "lib/stdio.h"
#include "sys/syscall.h"

// ch: 要输出的字符
uint64 sys_write(void) { 
    char ch;
    if (argint(0, &ch) < 0) {
        pr_error(sys_write, "argint(0, &ch) < 0");
        return -1;
    }
    printk("%c", ch);
    return 0;
}

// str: 读取字符串的目的地
// size: 读取字符串的最大尺寸
uint64 sys_read(void) { 
    char *str;
    int size;
    if (argaddr(0, &str) < 0) {
        pr_error(sys_read, "argaddr(0, &str) < 0");
        return -1;
    } else if (argint(1, &size) < 0) {
        pr_error(sys_read, "argint(1, &size) < 0");
        return -1;
    }
    return gets_k(str, size);
}